import React, { FC, ReactNode } from 'react';
import { StyleSheet, View, Text } from 'react-native';

interface PageTitleProps {
  title?: string;
  children?: ReactNode;
}

const PageTitle: FC<PageTitleProps> = ({ title, children }) => {
  return (
    <View style={styles.root}>
      {title && <Text style={styles.title}>{title}</Text>}
      {children}
    </View>
  );
};

const styles = StyleSheet.create({
  root: {
    width: '100%',
    height: 46,
    backgroundColor: '#fff',
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
  },
  title: {
    fontSize: 18,
    fontWeight: '500',
    color: '#333',
  }
});

export default PageTitle;
